
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>ST_ClusterDBSCAN · PostGIS中文指南</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="xxx">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-okaidia.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-folding-chapters/folding-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Clustering.html" />
    
    

    <script src="../gitbook/gitbook-plugin-graph/d3.min.js"></script>
    <script src="../gitbook/gitbook-plugin-graph/function-plot.js"></script>    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">第 Ⅰ 部分：PostGIS基础</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    一 初识PostGIS
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../introduction/PostgisAbility.html">
            
                <a href="../introduction/PostgisAbility.html">
            
                    
                    1.1 PostGIS特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../introduction/PostgisAbility.html">
            
                <a href="../introduction/PostgisAbility.html">
            
                    
                    1.2 PostGIS使用场景
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../installation/PostgreSQL Installation.html">
            
                <a href="../installation/PostgreSQL Installation.html">
            
                    
                    1.2.1 适用场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../installation/PostGIS Installation.html">
            
                <a href="../installation/PostGIS Installation.html">
            
                    
                    1.2.2 不适用场景
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../introduction/PostgisAbility.html">
            
                <a href="../introduction/PostgisAbility.html">
            
                    
                    1.3 PostGIS使用建议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" >
            
                <span>
            
                    
                    1.4 PostGIS安装
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.4.1" data-path="../installation/PostgreSQL Installation.html">
            
                <a href="../installation/PostgreSQL Installation.html">
            
                    
                    1.4.1 PostgreSQL安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.2" data-path="../installation/PostGIS Installation.html">
            
                <a href="../installation/PostGIS Installation.html">
            
                    
                    1.4.2 PostGIS安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../introduction/ReleaseNotes.html">
            
                <a href="../introduction/ReleaseNotes.html">
            
                    
                    1.5 PostGIS重大版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    二 PostGIS入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" >
            
                <span>
            
                    
                    2.1 客户端介绍
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" >
            
                <span>
            
                    
                    2.1.1 psql
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" >
            
                <span>
            
                    
                    2.1.2 qgis
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" >
            
                <span>
            
                    
                    2.2 空间数据库
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" >
            
                <span>
            
                    
                    2.3 数据导入
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" >
            
                <span>
            
                    
                    2.3.1 shp
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" >
            
                <span>
            
                    
                    2.3.2 csv
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.3" >
            
                <span>
            
                    
                    2.3.3 excel
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 Ⅱ 部分：API手册</li>
        
        
    
        <li class="chapter " data-level="2.1" >
            
                <span>
            
                    
                    八 矢量函数
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" >
            
                <span>
            
                    
                    8.2 空间表管理
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1.1" data-path="TableManager/AddGeometryColumn.html">
            
                <a href="TableManager/AddGeometryColumn.html">
            
                    
                    8.2.1 AddGeometryColumn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.2" data-path="TableManager/DropGeometryColumn.html">
            
                <a href="TableManager/DropGeometryColumn.html">
            
                    
                    8.2.2 DropGeometryColumn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.3" data-path="TableManager/DropGeometryTable.html">
            
                <a href="TableManager/DropGeometryTable.html">
            
                    
                    8.2.3 DropGeometryTable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.4" data-path="TableManager/Find_SRID.html">
            
                <a href="TableManager/Find_SRID.html">
            
                    
                    8.2.4 Find_SRID
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.5" data-path="TableManager/Populate_Geometry_Columns.html">
            
                <a href="TableManager/Populate_Geometry_Columns.html">
            
                    
                    8.2.5 Populate_Geometry_Columns
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.1.6" data-path="TableManager/UpdateGeometrySRID.html">
            
                <a href="TableManager/UpdateGeometrySRID.html">
            
                    
                    8.2.6 UpdateGeometrySRID
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.2" >
            
                <span>
            
                    
                    8.4 元数据读写
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.2.1" data-path="Accessors.html">
            
                <a href="Accessors.html#GeometryType">
            
                    
                    GeometryType
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.2" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_GeometryType">
            
                    
                    ST_GeometryType
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.3" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_CoordDim">
            
                    
                    ST_CoordDim与ST_NDims
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.4" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Dimension">
            
                    
                    ST_Dimension
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.5" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Zmflag">
            
                    
                    ST_Zmflag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.6" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_HasArc">
            
                    
                    ST_HasArc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.7" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsPolygonCCW">
            
                    
                    ST_IsPolygonCCW
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.8" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsPolygonCW">
            
                    
                    ST_IsPolygonCW
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.9" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsClosed">
            
                    
                    ST_IsClosed
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.10" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsCollection">
            
                    
                    ST_IsCollection
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.11" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsEmpty">
            
                    
                    ST_IsEmpty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.12" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsRing">
            
                    
                    ST_IsRing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.13" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_IsSimple">
            
                    
                    ST_IsSimple
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.14" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Boundary">
            
                    
                    ST_Boundary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.15" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Envelope">
            
                    
                    ST_Envelope
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.16" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_BoundingDiagonal">
            
                    
                    ST_BoundingDiagonal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.17" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_X">
            
                    
                    ST_X,ST_Y,ST_Z,ST_M
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.18" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_StartPoint">
            
                    
                    ST_StartPoint,ST_EndPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.19" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_NumGeometries">
            
                    
                    ST_NumGeometries,ST_GeometryN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.20" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_NRings">
            
                    
                    ST_NRings,ST_ExteriorRing,ST_NumInteriorRings,ST_NumInteriorRing,ST_InteriorRingN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.21" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_NumPatches">
            
                    
                    ST_NumPatches,ST_PatchN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.22" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_NPoints">
            
                    
                    ST_NPoints,ST_NumPoints,ST_PointN,ST_Points
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.23" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_MemSize">
            
                    
                    ST_MemSize
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.24" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Summary">
            
                    
                    ST_Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2.25" data-path="Accessors.html">
            
                <a href="Accessors.html#ST_Dump">
            
                    
                    ST_Dump,ST_DumpPoints,ST_DumpRings
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.3" >
            
                <span>
            
                    
                    8.11 空间关系
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.3.1" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Intersects">
            
                    
                    ST_Intersects
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.2" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Intersects">
            
                    
                    ST_Disjoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.3" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Contains">
            
                    
                    ST_Contains
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.4" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Contains">
            
                    
                    ST_Within
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.5" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Equals">
            
                    
                    ST_Equals
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.6" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_ContainsProperly">
            
                    
                    ST_ContainsProperly
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.7" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Covers">
            
                    
                    ST_Covers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.8" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Covers">
            
                    
                    ST_CoveredBy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.9" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Overlaps">
            
                    
                    ST_Overlaps
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.10" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Overlaps">
            
                    
                    ST_Crosses
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.11" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Touches">
            
                    
                    ST_Touches
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.12" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_Relate">
            
                    
                    ST_Relate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3.13" data-path="SpatialRelationships.html">
            
                <a href="SpatialRelationships.html#ST_RelateMatch">
            
                    
                    ST_RelateMatch
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.4" >
            
                <span>
            
                    
                    8.12 空间测量
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.4.1" data-path="Measurement/ST_3DClosestPoint.html">
            
                <a href="Measurement/ST_3DClosestPoint.html#ST_3DClosestPoint">
            
                    
                    ST_3DClosestPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.2" data-path="Measurement/ST_3DDistance.html">
            
                <a href="Measurement/ST_3DDistance.html">
            
                    
                    ST_3DDistance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.3" data-path="Measurement/ST_Angle.html">
            
                <a href="Measurement/ST_Angle.html">
            
                    
                    ST_Angle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.4" data-path="Measurement/ST_Area.html">
            
                <a href="Measurement/ST_Area.html">
            
                    
                    ST_Area
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.5" data-path="Measurement/ST_Azimuth.html">
            
                <a href="Measurement/ST_Azimuth.html">
            
                    
                    ST_Azimuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.6" data-path="Measurement/ST_ClosestPoint.html">
            
                <a href="Measurement/ST_ClosestPoint.html">
            
                    
                    ST_ClosestPoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.7" data-path="Measurement/ST_Distance.html">
            
                <a href="Measurement/ST_Distance.html">
            
                    
                    ST_Distance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4.8" data-path="Measurement/ST_Project.html">
            
                <a href="Measurement/ST_Project.html">
            
                    
                    ST_Project
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.5" >
            
                <span>
            
                    
                    8.14 仿射变换
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.5.1" data-path="AffineTransformations/ST_Affine.html">
            
                <a href="AffineTransformations/ST_Affine.html#ST_Affine">
            
                    
                    ST_Affine
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.2" data-path="AffineTransformations/ST_Rotate.html">
            
                <a href="AffineTransformations/ST_Rotate.html">
            
                    
                    ST_Rotate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.3" data-path="AffineTransformations/ST_RotateX.html">
            
                <a href="AffineTransformations/ST_RotateX.html">
            
                    
                    ST_RotateX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.4" data-path="AffineTransformations/ST_RotateY.html">
            
                <a href="AffineTransformations/ST_RotateY.html">
            
                    
                    ST_RotateY
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.5" data-path="AffineTransformations/ST_RotateZ.html">
            
                <a href="AffineTransformations/ST_RotateZ.html">
            
                    
                    ST_RotateZ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.6" data-path="AffineTransformations/ST_Scale.html">
            
                <a href="AffineTransformations/ST_Scale.html">
            
                    
                    ST_Scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.7" data-path="AffineTransformations/ST_Translate.html">
            
                <a href="AffineTransformations/ST_Translate.html">
            
                    
                    ST_Translate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5.8" data-path="AffineTransformations/ST_TransScale.html">
            
                <a href="AffineTransformations/ST_TransScale.html">
            
                    
                    ST_TransScale
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.6" >
            
                <span>
            
                    
                    8.15 空间聚类
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.6.1" data-path="Clustering.html">
            
                <a href="Clustering.html#ST_ClusterDBSCAN">
            
                    
                    ST_ClusterDBSCAN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.2" data-path="Clustering.html">
            
                <a href="Clustering.html#ST_ClusterIntersecting">
            
                    
                    ST_ClusterIntersecting
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.3" data-path="Clustering.html">
            
                <a href="Clustering.html#ST_ClusterKMeans">
            
                    
                    ST_ClusterKMeans
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6.4" data-path="Clustering.html">
            
                <a href="Clustering.html#ST_ClusterWithin">
            
                    
                    ST_ClusterWithin
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.1.7" >
            
                <span>
            
                    
                    8.16 线性参考
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.7.1" data-path="LinearReferencing/ST_LineInterpolatePoint.html">
            
                <a href="LinearReferencing/ST_LineInterpolatePoint.html">
            
                    
                    ST_LineInterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.2" data-path="LinearReferencing/ST_3dLineInterpolatePoint.html">
            
                <a href="LinearReferencing/ST_3dLineInterpolatePoint.html">
            
                    
                    ST_3dLineInterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.3" data-path="LinearReferencing/ST_LineInterpolatePoints.html">
            
                <a href="LinearReferencing/ST_LineInterpolatePoints.html">
            
                    
                    ST_LineInterpolatePoints
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.4" data-path="LinearReferencing/ST_LineLocatePoint.html">
            
                <a href="LinearReferencing/ST_LineLocatePoint.html">
            
                    
                    ST_LineLocatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.5" data-path="LinearReferencing/ST_LineSubstring.html">
            
                <a href="LinearReferencing/ST_LineSubstring.html">
            
                    
                    ST_LineSubstring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.6" data-path="LinearReferencing/ST_LocateAlong.html">
            
                <a href="LinearReferencing/ST_LocateAlong.html">
            
                    
                    ST_LocateAlong
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.7" data-path="LinearReferencing/ST_LocateBetween.html">
            
                <a href="LinearReferencing/ST_LocateBetween.html">
            
                    
                    ST_LocateBetween
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.8" data-path="LinearReferencing/ST_LocateBetweenElevations.html">
            
                <a href="LinearReferencing/ST_LocateBetweenElevations.html">
            
                    
                    ST_LocateBetweenElevations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.9" data-path="LinearReferencing/ST_InterpolatePoint.html">
            
                <a href="LinearReferencing/ST_InterpolatePoint.html">
            
                    
                    ST_InterpolatePoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.10" data-path="LinearReferencing/ST_AddMeasure.html">
            
                <a href="LinearReferencing/ST_AddMeasure.html">
            
                    
                    ST_AddMeasure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7.11" data-path="LinearReferencing/examples.html">
            
                <a href="LinearReferencing/examples.html">
            
                    
                    综合案例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 Ⅲ 部分：PostGIS++</li>
        
        
    

    
        
        <li class="header">第 Ⅳ 部分：常见问题</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >ST_ClusterDBSCAN</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="stclusterdbscan"><span id="ST_ClusterDBSCAN">ST_ClusterDBSCAN</span></h2>
<h3 id="&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;">&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;</h3>
<p>&#x7A97;&#x53E3;&#x51FD;&#x6570;&#xFF0C;&#x57FA;&#x4E8E;DBSCAN&#x7B97;&#x6CD5;&#xFF0C;&#x8FD4;&#x56DE;&#x6BCF;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x7684;geometry&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x805A;&#x7C7B;id&#x3002;</p>
<h3 id="&#x51FD;&#x6570;&#x5B9A;&#x4E49;">&#x51FD;&#x6570;&#x5B9A;&#x4E49;</h3>
<pre class="language-"><code>integer ST_ClusterDBSCAN(geometry winset geom, float8 eps, integer minpoints);
</code></pre><p>&#x5165;&#x53C2;&#xFF1A;</p>
<pre class="language-"><code>geom&#xFF1A;&#x8F93;&#x5165;&#x7684;2d&#x56FE;&#x5F62;&#x3002;

eps&#xFF1A;&#x805A;&#x7C7B;&#x8DDD;&#x79BB;&#xFF0C;&#x5F53;&#x4E24;&#x4E2A;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x8DDD;&#x79BB;&#x5C0F;&#x4E8E;&#x805A;&#x7C7B;&#x8DDD;&#x79BB;&#xFF0C;&#x4ED6;&#x4EEC;&#x88AB;&#x5F52;&#x4E3A;&#x4E00;&#x7C7B;&#x3002;

minpoints&#xFF1A;&#x89C4;&#x5B9A;&#x201C;&#x7C07;&#x201D;&#x4E2D;&#x81F3;&#x5C11;&#x5305;&#x542B;&#x7684;&#x56FE;&#x5F62;&#x6570;&#x91CF;&#x3002;
</code></pre><p>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5BF9;&#x5E94;&#x7684;&#x805A;&#x7C7B;id&#x53F7;&#xFF0C;&#x5982;&#x679C;&#x8F93;&#x5165;&#x7684;geom&#x4E0D;&#x5C5E;&#x4E8E;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x201C;&#x7C07;&#x201D;&#xFF0C;&#x5C06;&#x8FD4;&#x56DE;null&#x3002;</p>
<h3 id="&#x5E94;&#x7528;&#x793A;&#x4F8B;">&#x5E94;&#x7528;&#x793A;&#x4F8B;</h3>
<p>&#x4ECE;osm&#x7684;building&#x56FE;&#x5C42;&#x4E2D;&#x622A;&#x53D6;&#x4E86;&#x4E00;&#x5C0F;&#x90E8;&#x5206;&#x6D4B;&#x8BD5;&#x623F;&#x5C4B;&#x5EFA;&#x7B51;&#x6570;&#x636E;&#xFF0C;&#x57FA;&#x4E8E;ST_ClusterDBSCAN&#x65B9;&#x6CD5;&#xFF0C;&#x6839;&#x636E;&#x5EFA;&#x7B51;&#x4E4B;&#x95F4;&#x5C0F;&#x4E8E;20&#x7C73;&#xFF0C;&#x4E14;&#x6BCF;&#x4E00;&#x7C07;&#x4E2D;&#x81F3;&#x5C11;&#x5305;&#x542B;2&#x4E2A;&#x56FE;&#x5F62;&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterDBSCAN.png" alt=""></p>
<pre class="language-"><code>--&#x8868;&#x5750;&#x6807;&#x7CFB;&#x662F;epsg:4326&#x7684;&#x7ECF;&#x7EAC;&#x5EA6;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x91CC;&#x662F;&#x4F7F;&#x7528;0.0002&#x5927;&#x6982;&#x6A21;&#x62DF;20&#x7C73;&#xFF0C;&#x975E;&#x771F;&#x5B9E;&#x8DDD;&#x79BB;&#x3002;
SELECT gid,name, ST_ClusterDBSCAN(geom, eps:= 0.0002, minpoints := 2) 
over () AS cid FROM buildings;

gid |     name     | cid
-----+--------------+-----
   1 |              |
   2 |              |   2
   3 |              |   2
   4 |              |   2
   5 | &#x5927;&#x6D0B;&#x767E;&#x8D27;     |
   6 | &#x5546;&#x8302;&#x4E16;&#x7EAA;&#x5E7F;&#x573A; |   0
   7 | &#x534E;&#x5A01;&#x5927;&#x53A6;     |   2
   8 | &#x5929;&#x5B89;&#x4FDD;&#x9669;&#x5927;&#x53A6; |   2
   9 |              |   2
  10 |              |
  11 | &#x6C5F;&#x82CF;&#x4EA4;&#x901A;&#x5927;&#x53A6; |   2
  12 | &#x9633;&#x5149;&#x5927;&#x53A6;     |
  13 |              |   0
  14 |              |   2
  15 |              |   2
  16 |              |   2
  17 |              |   2
  18 |              |   1
  19 |              |   1
  20 |              |   2
  21 |              |   2
  22 |              |   2
  23 |              |   2
  24 |              |   2
  25 |              |   2
  26 |              |   2
  27 |              |   2
-- More  --
</code></pre><p>cid&#x662F;&#x6BCF;&#x4E2A;geom&#x6240;&#x5BF9;&#x5E94;&#x5EFA;&#x7B51;&#x7684;&#x805A;&#x7C7B;id&#x53F7;&#xFF0C;&#x7070;&#x8272;&#x5EFA;&#x7B51;&#x662F;&#x4E0E;&#x5176;&#x4ED6;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x8DDD;&#x79BB;&#x5927;&#x4E8E;20&#x7C73;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x5F52;&#x5165;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x201C;&#x7C07;&#x201D;&#xFF0C;&#x8FD4;&#x56DE;&#x7684;&#x805A;&#x7C7B;id&#x662F;null(cid null&#x7684;&#x8BB0;&#x5F55;&#x90FD;&#x662F;&#x7070;&#x8272;&#x7684;)&#x3002;</p>
<h2 id="stclusterintersecting"><span id="ST_ClusterIntersecting">ST_ClusterIntersecting</span></h2>
<h3 id="&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;">&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;</h3>
<p>&#x805A;&#x5408;&#x51FD;&#x6570;&#xFF0C;&#x5BF9;&#x4E8E;&#x8F93;&#x5165;&#x7684;&#x4E00;&#x4E2A;geometry&#x96C6;&#x5408;&#xFF0C;&#x96C6;&#x5408;&#x4E2D;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x6839;&#x636E;&#x201C;&#x7A7A;&#x95F4;&#x76F8;&#x4EA4;&#x201D;&#x8FDB;&#x884C;&#x805A;&#x7C7B;&#xFF0C;&#x6700;&#x540E;&#x628A;&#x805A;&#x7C7B;&#x7ED3;&#x679C;&#x805A;&#x5408;&#x6210;&#x4E00;&#x4E2A;geometry&#x6570;&#x7EC4;&#xFF0C;&#x6570;&#x7EC4;&#x91CC;&#x7684;&#x6BCF;&#x4E00;&#x9879;&#x4EE3;&#x8868;&#x201C;&#x4E00;&#x7C7B;&#x201D;&#x3002;</p>
<h3 id="&#x51FD;&#x6570;&#x5B9A;&#x4E49;">&#x51FD;&#x6570;&#x5B9A;&#x4E49;</h3>
<pre class="language-"><code>geometry[] ST_ClusterIntersecting(geometry set g);
</code></pre><p>&#x5165;&#x53C2;&#xFF1A;</p>
<pre class="language-"><code>g&#xFF1A;&#x8F93;&#x5165;&#x7684;2d&#x56FE;&#x5F62;&#x96C6;&#x5408;&#x3002;
</code></pre><p>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x6240;&#x6709;&#x7684;&#x56FE;&#x5F62;&#x5B8C;&#x6210;&#x805A;&#x7C7B;&#xFF0C;&#x6BCF;&#x4E00;&#x7C7B;&#x56FE;&#x5F62;&#x90FD;&#x662F;&#x4E00;&#x4E2A;GEOMETRYCOLLECTION&#xFF08;&#x56FE;&#x5F62;&#x96C6;&#x5408;&#xFF09;&#x5BF9;&#x8C61;&#xFF0C;&#x6240;&#x6709;&#x7C7B;&#x90FD;&#x585E;&#x5165;&#x4E00;&#x4E2A;geometry&#x6570;&#x7EC4;&#x91CC;&#x5E76;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</p>
<h3 id="&#x5E94;&#x7528;&#x793A;&#x4F8B;">&#x5E94;&#x7528;&#x793A;&#x4F8B;</h3>
<p>&#x793A;&#x4F8B;&#x6570;&#x636E;&#x793A;&#x610F;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterIntersecting1.png" alt="">
&#x5148;&#x6784;&#x9020;&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#xFF1A;</p>
<pre class="language-"><code>create table building2(
    gid serial primary key,
    name text,
    geom geometry(Polygon,4326)
);

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.77376608689 32.0424742122357,118.774542742962 32.0416518705121,118.773994515147 32.0411036426964,118.773172173423 32.0418802987687,118.77376608689 32.0424742122357))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.774222943403 32.0429310687489,118.775898083951 32.0413320709528,118.775456455989 32.0407838431371,118.774542742962 32.0416518705121,118.77376608689 32.0424742122357,118.774222943403 32.0429310687489))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.775898083951 32.0413320709528,118.777055453785 32.0402813009728,118.776629054372 32.0397635302578,118.775456455989 32.0407838431371,118.775898083951 32.0413320709528))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.771192461866 32.0393066737446,118.772684859809 32.0389259599839,118.772258460397 32.0379208756551,118.770705148252 32.0383320465169,118.771192461866 32.0393066737446))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.772258460397 32.0379208756551,118.772684859809 32.0389259599839,118.774375228908 32.0384234178194,118.773964058046 32.0375097047933,118.772258460397 32.0379208756551))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.776766111326 32.0381188468106,118.778045309563 32.0377076759488,118.778167137966 32.0373117336375,118.777695052903 32.0366721345192,118.776080826556 32.0371746766835,118.776766111326 32.0381188468106))&apos;,4326));

insert into building2(geom) values (ST_GeomFromText(&apos;POLYGON((118.778700137232 32.0380274755081,118.779857507065 32.0373878763897,118.779461564754 32.0368853342252,118.778730594333 32.0369614769774,118.778167137966 32.0373117336375,118.778045309563 32.0377076759488,118.778700137232 32.0380274755081))&apos;,4326));
</code></pre><p>&#x805A;&#x7C7B;&#x7ED3;&#x679C;&#x793A;&#x610F;&#x56FE;&#x5982;&#x4E0B;&#xFF1A;
<img src="http://localhost:4000/images/Clustering/ST_ClusterIntersecting2.png" alt=""></p>
<p>&#x6267;&#x884C;&#x805A;&#x7C7B;&#xFF1A;</p>
<pre class="language-"><code>select st_astext(unnest(ST_ClusterIntersecting(geom))) from building2;

                                                                    st_astext                                                                                                                                                                                                                                                                         
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 GEOMETRYCOLLECTION(POLYGON((118.77376608689 32.0424742122357,118.774542742962 32.0416518705121,118.773994515147 32.0411036426964,118.773172173423 32.0418802987687,118.77376608689 32.0424742122357)),POLYGON((118.774222943403 32.0429310687489,118.775898083951 32.0413320709528,118.775456455989 32.0407838431371,118.774542742962 32.0416518705121,118.77376608689 32.0424742122357,118.774222943403 32.0429310687489)),POLYGON((118.775898083951 32.0413320709528,118.777055453785 32.0402813009728,118.776629054372 32.0397635302578,118.775456455989 32.0407838431371,118.775898083951 32.0413320709528)))
 GEOMETRYCOLLECTION(POLYGON((118.771192461866 32.0393066737446,118.772684859809 32.0389259599839,118.772258460397 32.0379208756551,118.770705148252 32.0383320465169,118.771192461866 32.0393066737446)),POLYGON((118.772258460397 32.0379208756551,118.772684859809 32.0389259599839,118.774375228908 32.0384234178194,118.773964058046 32.0375097047933,118.772258460397 32.0379208756551)))
 GEOMETRYCOLLECTION(POLYGON((118.776766111326 32.0381188468106,118.778045309563 32.0377076759488,118.778167137966 32.0373117336375,118.777695052903 32.0366721345192,118.776080826556 32.0371746766835,118.776766111326 32.0381188468106)),POLYGON((118.778700137232 32.0380274755081,118.779857507065 32.0373878763897,118.779461564754 32.0368853342252,118.778730594333 32.0369614769774,118.778167137966 32.0373117336375,118.778045309563 32.0377076759488,118.778700137232 32.0380274755081)))
(3 &#x884C;&#x8BB0;&#x5F55;)
</code></pre><h3 id="&#x4F7F;&#x7528;&#x95EE;&#x9898;">&#x4F7F;&#x7528;&#x95EE;&#x9898;</h3>
<p>ST_ClusterIntersecting&#x662F;&#x4E2A;&#x805A;&#x5408;&#x51FD;&#x6570;&#xFF0C;&#x805A;&#x7C7B;&#x7684;&#x7ED3;&#x679C;&#x6700;&#x540E;&#x662F;&#x4E00;&#x4E2A;geometry[]&#x7C7B;&#x578B;&#xFF0C;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5C5E;&#x6027;&#x5B57;&#x6BB5;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5176;&#x5B9E;&#x805A;&#x7C7B;&#x540E;&#xFF0C;&#x60F3;&#x8981;&#x83B7;&#x53D6;&#x805A;&#x7C7B;&#x56FE;&#x5F62;&#x7ED3;&#x679C;&#x4E0E;&#x5C5E;&#x6027;&#x5173;&#x7CFB;&#xFF0C;&#x6BD4;&#x5982;&#x6211;&#x4EEC;&#x6CA1;&#x529E;&#x6CD5;&#x4ECE;ST_ClusterIntersecting&#x51FD;&#x6570;&#x7684;&#x7ED3;&#x679C;&#x4E2D;&#x8F93;&#x51FA;&#x5BF9;&#x5E94;&#x7684;gid&#x6216;&#x8005;name&#x7B49;&#x5176;&#x4ED6;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#x76EE;&#x524D;&#x53EA;&#x80FD;&#x901A;&#x8FC7;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;&#x53BB;&#x89E3;&#x51B3;&#x3002;</p>
<p>&#x7B2C;&#x4E00;&#x6B65;&#xFF1A;&#x7ED9;&#x539F;&#x56FE;&#x5F62;&#x65B0;&#x589E;&#x4E00;&#x5217;&#xFF0C;&#x5B58;&#x50A8;&#x4E00;&#x4E2A;&#x5FC5;&#x987B;&#x5728;&#x539F;&#x56FE;&#x5F62;&#x5185;&#x90E8;&#x7684;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code>alter table building2 add column centroid geometry(point,4326);
update building2 set centroid=ST_PointOnSurface(geom);
</code></pre><p>&#x7B2C;&#x4E8C;&#x6B65;&#xFF1A;&#x7ED9;&#x805A;&#x7C7B;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x7684;&#x805A;&#x7C7B;id&#xFF1A;</p>
<pre class="language-"><code>create extension &quot;uuid-ossp&quot;;

--&#x805A;&#x7C7B;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x7EC4;&#xFF0C;&#x90FD;&#x88AB;&#x5206;&#x914D;&#x4E86;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x7684;&#x805A;&#x7C7B;id
create table temp_ClusterIntersecting(
    cid uuid,
    geom geometry
);

insert into temp_ClusterIntersecting select uuid_generate_v4(),unnest(ST_ClusterIntersecting(geom)) from building2;
</code></pre><p>&#x7B2C;&#x4E09;&#x6B65;&#xFF1A;&#x8FD4;&#x56DE;&#x8981;&#x7D20;id&#x548C;&#x5BF9;&#x5E94;&#x805A;&#x7C7B;id&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterIntersecting3.png" alt=""></p>
<pre class="language-"><code>select b.gid,a.cid a from 
temp_ClusterIntersecting a,
building2 b where st_intersects(b.centroid,a.geom);
gid |  cid
-----------------------------------
1    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
2    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
3    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
4    | &quot;94c281e0-4667-4557-88ab-8ca927ebfe94&quot;
5    | &quot;94c281e0-4667-4557-88ab-8ca927ebfe94&quot;
6    | &quot;86daef2f-5cae-4a65-8208-433bf0c525e0&quot;
7    | &quot;86daef2f-5cae-4a65-8208-433bf0c525e0&quot;
</code></pre><p>&#x4E5F;&#x53EF;&#x4EE5;&#x5408;&#x8D77;&#x6765;&#x5199;&#xFF1A;</p>
<pre class="language-"><code>select b.gid,a.cid from 
(select uuid_generate_v4() as cid,unnest(ST_ClusterIntersecting(geom)) as geom from building2) a,
(select gid,ST_PointOnSurface(geom) as centroid from building2) b where st_intersects(b.centroid,a.geom);

gid |  cid
-----------------------------------
1    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
2    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
3    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
4    | &quot;94c281e0-4667-4557-88ab-8ca927ebfe94&quot;
5    | &quot;94c281e0-4667-4557-88ab-8ca927ebfe94&quot;
6    | &quot;86daef2f-5cae-4a65-8208-433bf0c525e0&quot;
</code></pre><p>&#x8FD9;&#x6837;&#xFF0C;&#x901A;&#x8FC7;gid&#x80FD;&#x5173;&#x8054;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x8BB0;&#x5F55;&#x5BF9;&#x5E94;&#x7684;&#x5176;&#x4ED6;&#x66F4;&#x591A;&#x5B57;&#x6BB5;&#x4FE1;&#x606F;&#xFF0C;&#x901A;&#x8FC7;cid&#x77E5;&#x9053;&#x54EA;&#x4E9B;&#x8BB0;&#x5F55;&#x662F;&#x4E00;&#x7EC4;&#x7684;&#x7B49;&#x5176;&#x4ED6;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5173;&#x4E8E;join&#x548C;&#x7A7A;&#x95F4;&#x67E5;&#x8BE2;&#x6027;&#x80FD;&#x4E0D;&#x662F;&#x672C;&#x8282;&#x4E3B;&#x8981;&#x9610;&#x8FF0;&#x91CD;&#x70B9;&#xFF0C;&#x672C;&#x8282;&#x63D0;&#x51FA;&#x7684;&#x65B9;&#x6848;&#x662F;&#x7406;&#x8BBA;&#x53EF;&#x884C;&#x65B9;&#x6848;&#xFF0C;&#x4F46;&#x662F;&#x57FA;&#x4E8E;&#x5B9E;&#x9645;&#x9879;&#x76EE;&#x548C;&#x6570;&#x636E;&#xFF0C;&#x5B58;&#x5728;&#x4F18;&#x5316;&#x7A7A;&#x95F4;&#xFF0C;&#x9700;&#x8981;&#x6839;&#x636E;&#x5176;&#x4ED6;postgis&#x4F18;&#x5316;&#x65B9;&#x6848;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;</p>
<h2 id="stclusterkmeans"><span id="ST_ClusterKMeans">ST_ClusterKMeans</span></h2>
<h3 id="&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;">&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;</h3>
<p>&#x7A97;&#x53E3;&#x51FD;&#x6570;&#xFF0C;&#x57FA;&#x4E8E;K-means&#x7B97;&#x6CD5;&#xFF0C;&#x8FD4;&#x56DE;&#x6BCF;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x7684;geometry&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x805A;&#x7C7B;id&#x3002;</p>
<h3 id="&#x51FD;&#x6570;&#x5B9A;&#x4E49;">&#x51FD;&#x6570;&#x5B9A;&#x4E49;</h3>
<pre class="language-"><code>integer ST_ClusterKMeans(geometry winset geom, integer number_of_clusters);
</code></pre><p>&#x5165;&#x53C2;&#xFF1A;</p>
<pre class="language-"><code>geom&#xFF1A;&#x8F93;&#x5165;&#x7684;2d&#x56FE;&#x5F62;&#x3002;

number_of_clusters&#xFF1A;&#x5747;&#x503C;&#x4E2D;&#x5FC3;&#x805A;&#x7C7B;&#x6307;&#x5B9A;&#x201C;&#x7C07;&#x201D;&#x7684;&#x6570;&#x91CF;&#x3002;
</code></pre><p>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5BF9;&#x5E94;&#x7684;&#x805A;&#x7C7B;id&#x53F7;&#xFF0C;&#x5982;&#x679C;&#x8F93;&#x5165;&#x7684;geom&#x4E0D;&#x5C5E;&#x4E8E;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x201C;&#x7C07;&#x201D;&#xFF0C;&#x5C06;&#x8FD4;&#x56DE;null</p>
<h3 id="&#x5E94;&#x7528;&#x793A;&#x4F8B;">&#x5E94;&#x7528;&#x793A;&#x4F8B;</h3>
<p>&#x4ECE;osm&#x7684;building&#x56FE;&#x5C42;&#x4E2D;&#x622A;&#x53D6;&#x4E86;&#x4E00;&#x5C0F;&#x90E8;&#x5206;&#x6D4B;&#x8BD5;&#x623F;&#x5C4B;&#x5EFA;&#x7B51;&#x6570;&#x636E;&#xFF0C;&#x57FA;&#x4E8E;ST_ClusterKMeans&#x7A7A;&#x95F4;&#x805A;&#x5408;&#xFF0C;&#x6307;&#x5B9A;&#x5206;&#x7C7B;&#x6570;&#x91CF;&#x4E3A;3&#xFF0C;&#x8FD4;&#x56DE;&#x6BCF;&#x4E2A;&#x8BB0;&#x5F55;&#x7684;id&#x548C;&#x5BF9;&#x5E94;&#x7684;&#x805A;&#x7C7B;id&#xFF08;cid&#xFF09;&#x53F7;&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterKMeans1.png" alt=""></p>
<pre class="language-"><code>SELECT gid,ST_ClusterKMeans(geom,3) over () AS cid,geom FROM buildings;
</code></pre><p>&#x6307;&#x5B9A;&#x5206;&#x7C7B;&#x6570;&#x91CF;&#x4E3A;4&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterKMeans2.png" alt=""></p>
<pre class="language-"><code>SELECT gid,ST_ClusterKMeans(geom,4) over () AS cid,geom FROM buildings;
</code></pre><h2 id="stclusterwithin"><span id="ST_ClusterWithin">ST_ClusterWithin</span></h2>
<h3 id="&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;">&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x63CF;&#x8FF0;</h3>
<p>&#x805A;&#x5408;&#x51FD;&#x6570;&#xFF0C;&#x5BF9;&#x8F93;&#x5165;&#x7684;&#x56FE;&#x5F62;&#x96C6;&#x5408;&#xFF0C;&#x5982;&#x679C;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x8DDD;&#x79BB;&#x5185;&#xFF0C;&#x5219;&#x5F52;&#x5E76;&#x4E3A;&#x4E00;&#x7C7B;&#x3002;&#x4E0E;ST_ClusterIntersecting&#x7C7B;&#x4F3C;&#xFF0C;&#x53EA;&#x662F;ST_ClusterIntersecting&#x6307;&#x5B9A;&#x662F;&#x56FE;&#x5F62;&#x5FC5;&#x987B;&#x76F8;&#x4EA4;&#xFF0C;&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x8DDD;&#x79BB;&#x662F;0&#xFF0C;&#x800C;ST_ClusterWithin&#x4E0D;&#x9700;&#x8981;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x76F8;&#x4EA4;&#x5173;&#x7CFB;&#xFF0C;&#x800C;&#x662F;&#x8BF4;&#x5373;&#x4F7F;&#x56FE;&#x5F62;&#x4E0D;&#x76F8;&#x4EA4;&#xFF0C;&#x4F46;&#x662F;&#x5F53;&#x56FE;&#x5F62;&#x7684;&#x8DDD;&#x79BB;&#x5728;&#x6240;&#x89C4;&#x5B9A;&#x7684;&#x5BB9;&#x5DEE;&#x5185;&#xFF0C;&#x5C31;&#x53EF;&#x8BA4;&#x4E3A;&#x4ED6;&#x4EEC;&#x662F;&#x4E00;&#x7C7B;&#x3002;</p>
<h3 id="&#x51FD;&#x6570;&#x5B9A;&#x4E49;">&#x51FD;&#x6570;&#x5B9A;&#x4E49;</h3>
<pre class="language-"><code>geometry[] a(geometry set g, float8 distance);
</code></pre><p>&#x5165;&#x53C2;&#xFF1A;</p>
<pre class="language-"><code>g&#xFF1A;&#x8F93;&#x5165;&#x7684;2d&#x56FE;&#x5F62;&#x96C6;&#x5408;&#x3002;
distance&#xFF1A;&#x8DDD;&#x79BB;&#x5BB9;&#x5DEE;&#x3002;
</code></pre><p>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x6240;&#x6709;&#x7684;&#x56FE;&#x5F62;&#x5B8C;&#x6210;&#x805A;&#x7C7B;&#xFF0C;&#x6BCF;&#x4E00;&#x7C7B;&#x56FE;&#x5F62;&#x90FD;&#x662F;&#x4E00;&#x4E2A;GEOMETRYCOLLECTION&#xFF08;&#x56FE;&#x5F62;&#x96C6;&#x5408;&#xFF09;&#x5BF9;&#x8C61;&#xFF0C;&#x6240;&#x6709;&#x7C7B;&#x90FD;&#x585E;&#x5165;&#x4E00;&#x4E2A;geometry&#x6570;&#x7EC4;&#x91CC;&#x5E76;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</p>
<h3 id="&#x5E94;&#x7528;&#x793A;&#x4F8B;">&#x5E94;&#x7528;&#x793A;&#x4F8B;</h3>
<p>&#x4ECE;osm&#x7684;building&#x56FE;&#x5C42;&#x4E2D;&#x622A;&#x53D6;&#x4E86;&#x4E00;&#x5C0F;&#x90E8;&#x5206;&#x6D4B;&#x8BD5;&#x623F;&#x5C4B;&#x5EFA;&#x7B51;&#x6570;&#x636E;&#xFF0C;&#x57FA;&#x4E8E;ST_ClusterWithin&#x7A7A;&#x95F4;&#x805A;&#x7C7B;&#xFF0C;&#x6307;&#x5B9A;&#x805A;&#x7C7B;&#x6761;&#x4EF6;&#x662F;&#x56FE;&#x5F62;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#x5C0F;&#x4E8E;50&#x7C73;&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterWithin1.png" alt=""></p>
<pre class="language-"><code>select unnest(ST_ClusterWithin(geom, 0.0005)) geom from buildings;
</code></pre><p>&#x6307;&#x5B9A;&#x805A;&#x7C7B;&#x6761;&#x4EF6;&#x662F;&#x56FE;&#x5F62;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#x5C0F;&#x4E8E;30&#x7C73;&#xFF1A;</p>
<p><img src="http://localhost:4000/images/Clustering/ST_ClusterWithin2.png" alt=""></p>
<pre class="language-"><code>select unnest(ST_ClusterWithin(geom, 0.0003)) geom from buildings;
</code></pre><h3 id="&#x4F7F;&#x7528;&#x95EE;&#x9898;">&#x4F7F;&#x7528;&#x95EE;&#x9898;</h3>
<p>ST_ClusterWithin&#x662F;&#x4E2A;&#x805A;&#x5408;&#x51FD;&#x6570;&#xFF0C;&#x805A;&#x7C7B;&#x7684;&#x7ED3;&#x679C;&#x6700;&#x540E;&#x662F;&#x4E00;&#x4E2A;geometry[]&#x7C7B;&#x578B;&#xFF0C;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5C5E;&#x6027;&#x5B57;&#x6BB5;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5176;&#x5B9E;&#x805A;&#x7C7B;&#x540E;&#xFF0C;&#x60F3;&#x8981;&#x83B7;&#x53D6;&#x805A;&#x7C7B;&#x56FE;&#x5F62;&#x7ED3;&#x679C;&#x4E0E;&#x5C5E;&#x6027;&#x5173;&#x7CFB;&#xFF0C;&#x6BD4;&#x5982;&#x6211;&#x4EEC;&#x6CA1;&#x529E;&#x6CD5;&#x4ECE;ST_ClusterWithin&#x51FD;&#x6570;&#x7684;&#x7ED3;&#x679C;&#x4E2D;&#x8F93;&#x51FA;&#x5BF9;&#x5E94;&#x7684;gid&#x6216;&#x8005;name&#x7B49;&#x5176;&#x4ED6;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#x76EE;&#x524D;&#x53EA;&#x80FD;&#x901A;&#x8FC7;&#x56FE;&#x5F62;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;&#x53BB;&#x89E3;&#x51B3;&#x3002;</p>
<p>&#x7B2C;&#x4E00;&#x6B65;&#xFF1A;&#x7ED9;&#x539F;&#x56FE;&#x5F62;&#x65B0;&#x589E;&#x4E00;&#x5217;&#xFF0C;&#x5B58;&#x50A8;&#x4E00;&#x4E2A;&#x5FC5;&#x987B;&#x5728;&#x539F;&#x56FE;&#x5F62;&#x5185;&#x90E8;&#x7684;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code>alter table buildings add column centroid geometry(point,4326);
update buildings set centroid=ST_PointOnSurface(geom);
</code></pre><p>&#x7B2C;&#x4E8C;&#x6B65;&#xFF1A;&#x7ED9;&#x805A;&#x7C7B;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x7684;&#x805A;&#x7C7B;id&#xFF1A;</p>
<pre class="language-"><code>create extension &quot;uuid-ossp&quot;;

--&#x805A;&#x7C7B;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x7EC4;&#xFF0C;&#x90FD;&#x88AB;&#x5206;&#x914D;&#x4E86;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x7684;&#x805A;&#x7C7B;id
create table temp_ClusterWithin(
    cid uuid,
    geom geometry
);

insert into temp_ClusterWithin select uuid_generate_v4(),unnest(ST_ClusterWithin(geom&#xFF0C;0.0005)) from buildings;
</code></pre><p>&#x7B2C;&#x4E09;&#x6B65;&#xFF1A;&#x8FD4;&#x56DE;&#x8981;&#x7D20;id&#x548C;&#x5BF9;&#x5E94;&#x805A;&#x7C7B;id&#xFF1A;</p>
<pre class="language-"><code>select b.gid,a.cid a from 
temp_ClusterWithin a,
buildings b where st_intersects(b.centroid,a.geom);
gid |  cid
-----------------------------------
1    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
2    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
3    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
(More rows)
</code></pre><p>&#x4E5F;&#x53EF;&#x4EE5;&#x5408;&#x8D77;&#x6765;&#x5199;&#xFF1A;</p>
<pre class="language-"><code>select b.gid,a.cid from 
(select uuid_generate_v4() as cid,unnest(ST_ClusterWithin(geom&#xFF0C;0.0005))) as geom from buildings) a,
(select gid,ST_PointOnSurface(geom) as centroid from buildings) b where st_intersects(b.centroid,a.geom);

gid |  cid
-----------------------------------
1    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
2    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
3    | &quot;d0d3a0db-41e4-4858-a98a-3279cf776fce&quot;
(More rows)
</code></pre><p>&#x8FD9;&#x6837;&#xFF0C;&#x901A;&#x8FC7;gid&#x80FD;&#x5173;&#x8054;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x8BB0;&#x5F55;&#x5BF9;&#x5E94;&#x7684;&#x5176;&#x4ED6;&#x66F4;&#x591A;&#x5B57;&#x6BB5;&#x4FE1;&#x606F;&#xFF0C;&#x901A;&#x8FC7;cid&#x77E5;&#x9053;&#x54EA;&#x4E9B;&#x8BB0;&#x5F55;&#x662F;&#x4E00;&#x7EC4;&#x7684;&#x7B49;&#x5176;&#x4ED6;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5173;&#x4E8E;join&#x548C;&#x7A7A;&#x95F4;&#x67E5;&#x8BE2;&#x6027;&#x80FD;&#x4E0D;&#x662F;&#x672C;&#x8282;&#x4E3B;&#x8981;&#x9610;&#x8FF0;&#x91CD;&#x70B9;&#xFF0C;&#x672C;&#x8282;&#x63D0;&#x51FA;&#x7684;&#x65B9;&#x6848;&#x662F;&#x7406;&#x8BBA;&#x53EF;&#x884C;&#x65B9;&#x6848;&#xFF0C;&#x4F46;&#x662F;&#x57FA;&#x4E8E;&#x5B9E;&#x9645;&#x9879;&#x76EE;&#x548C;&#x6570;&#x636E;&#xFF0C;&#x5B58;&#x5728;&#x4F18;&#x5316;&#x7A7A;&#x95F4;&#xFF0C;&#x9700;&#x8981;&#x6839;&#x636E;&#x5176;&#x4ED6;postgis&#x4F18;&#x5316;&#x65B9;&#x6848;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="Clustering.html#ST_ClusterIntersecting" class="navigation navigation-next navigation-unique" aria-label="Next page: ST_ClusterIntersecting">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"ST_ClusterDBSCAN","level":"2.1.6.1","depth":3,"next":{"title":"ST_ClusterIntersecting","level":"2.1.6.2","depth":3,"anchor":"#ST_ClusterIntersecting","path":"vector_function/Clustering.md","ref":"vector_function/Clustering.md#ST_ClusterIntersecting","articles":[]},"previous":{"title":"8.15 空间聚类","level":"2.1.6","depth":2,"ref":"","articles":[{"title":"ST_ClusterDBSCAN","level":"2.1.6.1","depth":3,"anchor":"#ST_ClusterDBSCAN","path":"vector_function/Clustering.md","ref":"vector_function/Clustering.md#ST_ClusterDBSCAN","articles":[]},{"title":"ST_ClusterIntersecting","level":"2.1.6.2","depth":3,"anchor":"#ST_ClusterIntersecting","path":"vector_function/Clustering.md","ref":"vector_function/Clustering.md#ST_ClusterIntersecting","articles":[]},{"title":"ST_ClusterKMeans","level":"2.1.6.3","depth":3,"anchor":"#ST_ClusterKMeans","path":"vector_function/Clustering.md","ref":"vector_function/Clustering.md#ST_ClusterKMeans","articles":[]},{"title":"ST_ClusterWithin","level":"2.1.6.4","depth":3,"anchor":"#ST_ClusterWithin","path":"vector_function/Clustering.md","ref":"vector_function/Clustering.md#ST_ClusterWithin","articles":[]}]},"dir":"ltr"},"config":{"plugins":["pageview-count","prism","-highlight","custom-favicon","-sharing","emphasize","-lunr","-search","search-pro","graph","splitter","hide-element","folding-chapters"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-okaidia.css"]},"emphasize":{},"splitter":{},"search-pro":{},"graph":{},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"folding-chapters":{},"favicon":"../gitbook/images/favicon.ico","pageview-count":{},"custom-favicon":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"xxx","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"service":"http://localhost:4000"},"title":"PostGIS中文指南","gitbook":"*","description":"记录PostGIS使用入门，进阶，提高，附带API全解析"},"file":{"path":"vector_function/Clustering.md","mtime":"2024-07-23T08:43:00.302Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-07-23T09:36:52.257Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-folding-chapters/folding-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

